<?php
//
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
if($_RQ['op']=='main'){
	$return['member']=model('core/member')->detail($_SESSION['uid'],array('credit1','credit2','credit3','credit4','credit6','mobile','avatar','nickname'));
	$return['pluginset']['hdps']=$return['pluginset']['canghdps'];
	$return['pluginset']['bankuai']=$return['pluginset']['cangbankuai'];
	$return['red']=$_SESSION['member'];
	$return['red']['allfee']=$this->pdo_getsum('feelog',array('type'=>2,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$return['red']['isfee']=$this->pdo_getsum('feelog',array('type'=>2,'status'=>1,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$return['red']['lastfee']=$this->pdo_getsum('feelog',array('type'=>2,'status'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']),'fee');
	$return['red']['red_mp3']=$return['pluginset']['red_mp3'];
	$sharelink='jy_guashop/cang//fromuser='.$_SESSION['uid'];
	$return['sharedata']=array(
			'title'=>$this->setting['share_title']?:'挂卖商城-在线挂卖',
			'desc'=>$this->setting['share_desc']?:'挂卖商城，参与挂卖！',
			'link'=>custom_url($sharelink,true),
			'imgUrl'=>ATTACHMENT_URL.$return['pluginset']['logo']
	);
	set_html('title','挂卖商城');
	exi($return);
}
if($_RQ['op']=='getlist'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($_RQ['keyword']){
		$params['title like']='%;'.$_RQ['keyword'].';%';
	}
    $orderby='createtime desc';
	$total='';
	$list=pdo_getslice('jy_guashop_goods',$params,array($pindex,$psize),$total,'','','id desc');
	if($list){
		$day=date('Y/m/d');
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['statustitle']=$this->goods_status[$item['status']];
			$log=pdo_get('jy_creditshop_log',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['logid']));
			$item['goods']=pdo_get('jy_creditshop_goods',array('uniacid'=>$_SESSION['uniacid'],'id'=>$log['goodsid']),array('title','thumb'));
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='getred'){
	$post=get_postdata();	
	$id=intval($post['id']);
	$sale_reds=$this->pdo_getall('feelog',array('type'=>2,'status'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	if(empty($sale_reds)){
		exi('没有红包可领取！','error');
	}
	foreach($sale_reds as $sv){
		if($sv['gift_type'] && $sv['fee']>0){
			$red=array(
				'mid'=>$_SESSION['uid'],
				'money'=>$sv['fee'],
				'plugin'=>'jy_guashop',
				'remark'=>'参与挂卖红包提现',
			);
			model('core/red_pack')->get_money($red);
		}
	}
	$this->pdo_update('feelog',array('status'=>1),array('type'=>2,'status'=>0,'mid'=>$_SESSION['uid'],'uniacid'=>$_SESSION['uniacid']));
	exi('领取成功！');
}
?>